package com.fms.player.mvc.mediator
{
	import com.fms.player.mvc.FMSFacade;
	import com.fms.player.ui.common.PublishStream;
	import com.fms.player.ui.live.teacher.TeacherLivePlayer;
	import com.fms.player.util.DividedGroup;
	
	import flash.events.MouseEvent;
	
	import mx.controls.Alert;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	public class TeacherLiveMediator extends Mediator
	{
		public static const NAME:String = 'TeacherLiveMediator';
		
		public function TeacherLiveMediator(viewComponent:Object=null)
		{
			super(NAME, viewComponent);
			addEventListener();
		}
		
		override public function handleNotification(notification:INotification):void
		{
			switch(notification.getName()){
				
			}
		}
		
		override public function listNotificationInterests():Array{
			return [];
		}
		
		public function get view():TeacherLivePlayer
		{
			return viewComponent as TeacherLivePlayer;
		}
		
		private function addEventListener():void{
			view.startLiveBtn.addEventListener(MouseEvent.CLICK, startLiveEvt);
		}
		
		private function startLiveEvt(e:MouseEvent):void{
			//创建一个房间
			var publishStream:PublishStream = new PublishStream(DividedGroup.getNewGroup("00001", "000013"), "00001"+"000013"+"Subject");
			view.addElement(publishStream);
		}
		
		private function removeEventListener():void{
			view.startLiveBtn.removeEventListener(MouseEvent.CLICK, startLiveEvt);
		}
		
		override public function onRemove():void
		{
			removeEventListener();
			view.removeAllElements();
		}
	}
}